$(function(){
    let form = layui.form
    form.verify({
        pwd:[
            /^[\S]{6,12}$/,
            '密码必须6到12位，且不能出现空格'
        ],
        newPwd: function (value) {
            let v1 =$('[name=oldPwd]').val()
            if(value == v1) return '新密码和旧密码不能相同！'
        },
        rePwd:function (value) {
            let v2 = $('[name=newPwd]').val()
            if(value != v2 ) return '两次密码输入不一致！'
        },
    })

    $('form').on('submit',function(e){
        e.preventDefault()
        axios({
            url:'/my/updatepwd',
            method:'post',
            data: $(this).serialize()
        }).then(({data:res})=>{
            if (res.status != 0 ) return layui.layer.msg(res.message)
            layer.msg("恭喜您！密码修改成功！")
            $('#formPwd')[0].reset()
        });
    })






})
